import { ConfigService } from '../core/common/config.service';
import { httpFactory } from '../core/http/http.factory';
import { NgModule, ModuleWithProviders } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule, Router } from '@angular/router';
import { ToasterModule } from 'angular2-toaster/angular2-toaster';
import { AlertModule } from 'ngx-bootstrap/alert';
import { ButtonsModule } from 'ngx-bootstrap/buttons';
import { CarouselModule } from 'ngx-bootstrap/carousel';
import { CollapseModule } from 'ngx-bootstrap/collapse';
import { BsDropdownModule } from 'ngx-bootstrap/dropdown';
import { DropdownModule } from 'primeng/primeng';
import { SharedModule } from 'primeng/primeng';
import { ModalModule } from 'ngx-bootstrap/modal';
import { PaginationModule } from 'ngx-bootstrap/pagination';
import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
import { RatingModule } from 'ngx-bootstrap/rating';
import { TimepickerModule } from 'ngx-bootstrap/timepicker';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { TypeaheadModule } from 'ngx-bootstrap/typeahead';
import { AccordionModule } from 'primeng/primeng';
import { FileUploadModule } from 'primeng/primeng';

import { DataTableModule } from './component/primeng/datatable/datatable';
import { FlotDirective } from './directives/flot/flot.directive';
import { SparklineDirective } from './directives/sparkline/sparkline.directive';
import { EasypiechartDirective } from './directives/easypiechart/easypiechart.directive';
import { ColorsService } from './colors/colors.service';
import { NKDatetimeModule } from './component/ng2-datetime/ng2-datetime.module';
import { SelectModule } from './component/ng2-select/select.module';
import { Ng2TableModule } from './component/ng2-table/ng-table-module';
import { TabsModule } from './component/ngx-bootstrap';
import { CheckallDirective } from './directives/checkall/checkall.directive';
import { VectormapDirective } from './directives/vectormap/vectormap.directive';
import { NowDirective } from './directives/now/now.directive';
import { ScrollableDirective } from './directives/scrollable/scrollable.directive';
import { JqcloudDirective } from './directives/jqcloud/jqcloud.directive';
import { Http, XHRBackend, RequestOptions } from '@angular/http';
import { TranslateModule } from '@ngx-translate/core';
import { TabViewModule } from 'primeng/primeng';

import { BaiduMapModule } from './component/ng2-baidumap/map.module';
import { PhoneValidatorDirective } from './directives/phoneValidator.directive';

@NgModule({
  imports: [
    CommonModule,
    FormsModule,
    ReactiveFormsModule,
    TranslateModule,
    NKDatetimeModule,
    SelectModule,
    TabsModule.forRoot(),
    Ng2TableModule,
    AccordionModule,
    DataTableModule,
    SharedModule,
    FileUploadModule,
    AlertModule.forRoot(),
    ButtonsModule.forRoot(),
    CarouselModule.forRoot(),
    CollapseModule.forRoot(),
    BsDropdownModule.forRoot(),
    ModalModule.forRoot(),
    PaginationModule.forRoot(),
    ProgressbarModule.forRoot(),
    RatingModule.forRoot(),
    TimepickerModule.forRoot(),
    TooltipModule.forRoot(),
    TypeaheadModule.forRoot(),
    ToasterModule,
    Ng2TableModule,
    DropdownModule,
    TabViewModule,
    BaiduMapModule
  ],
  providers: [
    ColorsService, {
      provide: Http,
      useFactory: httpFactory,
      deps: [XHRBackend, RequestOptions, ConfigService, Router]
    }
  ],
  declarations: [
    FlotDirective,
    SparklineDirective,
    EasypiechartDirective,
    CheckallDirective,
    VectormapDirective,
    NowDirective,
    ScrollableDirective,
    JqcloudDirective,
    PhoneValidatorDirective
  ],
  exports: [
    CommonModule,
    FormsModule,
    SharedModule,
    ReactiveFormsModule,
    TranslateModule,
    RouterModule,
    AccordionModule,
    AlertModule,
    ButtonsModule,
    DropdownModule,
    CarouselModule,
    CollapseModule,
    BsDropdownModule,
    ModalModule,
    PaginationModule,
    ProgressbarModule,
    RatingModule,
    TimepickerModule,
    TooltipModule,
    FileUploadModule,
    TypeaheadModule,
    ToasterModule,
    FlotDirective,
    SparklineDirective,
    EasypiechartDirective,
    CheckallDirective,
    VectormapDirective,
    NowDirective,
    ScrollableDirective,
    JqcloudDirective,
    SelectModule,
    Ng2TableModule,
    NKDatetimeModule,
    TabsModule,
    DataTableModule,
    TabViewModule,
    PhoneValidatorDirective,
    BaiduMapModule
  ]
})

export class CloudSharedModule {
  static forRoot(): ModuleWithProviders {
    return {
      ngModule: CloudSharedModule
    };
  }
}
